package com.qf.service.impl;

import com.qf.entity.TbBrandGood;
import com.qf.dao.TbBrandGoodDao;
import com.qf.service.TbBrandGoodService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TbBrandGood)表服务实现类
 *
 * @author makejava
 * @since 2021-04-06 09:44:31
 */
@Service("tbBrandGoodService")
public class TbBrandGoodServiceImpl implements TbBrandGoodService {
    @Resource
    private TbBrandGoodDao tbBrandGoodDao;

    /**
     * 通过ID查询单条数据
     *
     * @param brandGoodId 主键
     * @return 实例对象
     */
    @Override
    public TbBrandGood queryById(Integer brandGoodId) {
        return this.tbBrandGoodDao.queryById(brandGoodId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<TbBrandGood> queryAllByLimit(int offset, int limit) {
        return this.tbBrandGoodDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param tbBrandGood 实例对象
     * @return 实例对象
     */
    @Override
    public TbBrandGood insert(TbBrandGood tbBrandGood) {
        this.tbBrandGoodDao.insert(tbBrandGood);
        return tbBrandGood;
    }

    /**
     * 修改数据
     *
     * @param tbBrandGood 实例对象
     * @return 实例对象
     */
    @Override
    public TbBrandGood update(TbBrandGood tbBrandGood) {
        this.tbBrandGoodDao.update(tbBrandGood);
        return this.queryById(tbBrandGood.getBrandGoodId());
    }

    /**
     * 通过主键删除数据
     *
     * @param brandGoodId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer brandGoodId) {
        return this.tbBrandGoodDao.deleteById(brandGoodId) > 0;
    }
}